package com.cfpamf.ms.insur.pay.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * Swagger webapi 文档生成
 *
 * @author zhangnayi
 */
@Configuration
public class SwaggerConfig {

    /**
     * 扫描api配置
     *
     * @return
     */
    @Bean
    public Docket createAdminRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .apiInfo(apiAminInfo())
                .groupName("小额保险支付系统")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cfpamf.ms.insur.pay.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * api显示配置
     *
     * @return
     */
    private ApiInfo apiAminInfo() {
        return new ApiInfoBuilder()
                .title("小额保险支付系统对接API接口")
                .termsOfServiceUrl("http://www.cfpamf.org.cn")
                .contact(new Contact("", "", ""))
                .version("1.0-SNAPSHOT")
                .build();
    }
}